﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using QiAdmin.Core;
using QiAdmin.Core.Attributes;
using QiAdmin.Core.Models;
using QiAdmin.Model.Dtos.Input;
using QiAdmin.Service.IService;
using QiAdmin.Service.Service;

namespace QiAdmin.WebApi.Controllers.System
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SysDeptController : ControllerBase
    {
        readonly ITSysDeptService _sysDeptService;
        readonly ITSysMenuService _sysMenuService;
        public SysDeptController(ITSysDeptService sysDeptService, ITSysMenuService sysMenuService)
        {
            _sysDeptService = sysDeptService;
            _sysMenuService = sysMenuService;
        }

        [Permission(PermissionType.Add)]
        [HttpPost]
        public ApiJsonResult Add(TSysDept_IN input)
        {
            var res = _sysDeptService.Add(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Edit)]
        [HttpPost]
        public ApiJsonResult Edit(TSysDept_IN input)
        {
            var res = _sysDeptService.Edit(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Query)]
        [HttpPost]
        public ApiJsonResult Get(TSysDept_IN input)
        {
            var res = _sysDeptService.Get(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Delete)]
        [HttpPost]
        public ApiJsonResult RemoveDept(TSysDept_IN input)
        {
            var res = _sysDeptService.RemoveDept(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Query)]
        [HttpPost]
        public ApiJsonResult GetDepts(TSysDept_IN input)
        {
            var res = _sysDeptService.GetDepts(input);
            return ApiJsonResult.Convert(res);
        }
    }
}
